local juesi = fk.CreateSkill {

  name = "joysp__juesi",

  tags = {  },

}



juesi:addEffect("active", {
  name = "joysp__juesi",
  anim_type = "offensive",
  card_num = 1,
  target_num = 1,
  can_use = function(self, player)
    return not player:isKongcheng()
  end,
  card_filter = function(self, player, to_select, selected)
    return #selected == 0 and Fk:getCardById(to_select).trueName == "slash" and not player:prohibitDiscard(Fk:getCardById(to_select))
  end,
  target_filter = function(self, player, to_select, selected)
    local target = Fk:currentRoom():getPlayerById(to_select)
    return #selected == 0 and not target:isNude() and player:inMyAttackRange(target)
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    room:throwCard(effect.cards, juesi.name, player, player)
    local card = room:askForDiscard(target, 1, 1, true, juesi.name, false, ".", "#joy__juesi-discard:"..player.id)
    if #card > 0 then
      card = Fk:getCardById(card[1])
      if card.trueName ~= "slash" and  player.hp  <= target.hp  and not player.dead and not target.dead then
        if player.room:askForSkillInvoke(player,juesi.name,".","#joy__juesi-drawCards") then
          player:drawCards(2,juesi.name)
        end
      elseif card.trueName == "slash"  and not player.dead and not target.dead then
        room:useVirtualCard("duel", nil, player, target, juesi.name)
      end
    end
  end,
})

return juesi